package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/schema/field"
	"time"
)

// Goal holds the schema definition for the Goal entity.
type Goal struct {
	ent.Schema
}

// Fields of the Goal.
func (Goal) Fields() []ent.Field {
	return []ent.Field{
		field.String("title").
			NotEmpty().
			Comment("标题"),
		field.String("type").
			Default("其他").
			Comment("类型：存钱/健身/学习/其他"),
		field.Float("target_value").
			Default(0).
			Comment("目标值"),
		field.Float("current_value").
			Default(0).
			Comment("当前值"),
		field.String("unit").
			Default("").
			Comment("单位"),
		field.Time("deadline").
			Optional().
			Nillable().
			Comment("截止日期"),
		field.String("status").
			Default("进行中").
			Comment("状态：进行中/已完成/已放弃"),
		field.Time("created_at").
			Default(time.Now).
			Immutable().
			Comment("创建时间"),
		field.Time("updated_at").
			Default(time.Now).
			UpdateDefault(time.Now).
			Comment("更新时间"),
	}
}

// Edges of the Goal.
func (Goal) Edges() []ent.Edge {
	return nil
}
